const mongose = require('mongoose');

module.exports.getRent3 = async function(){
    const allData =  await mongose.model('commentsModel').find().populate('orderId').populate('userId');
    return await allData.filter( item =>{
        return item.userId.isMerchant == false;
    });
};

module.exports.getRentStatus = async function({status}){
    const allData =  await mongose.model('commentsModel').find({status}).populate('orderId').populate('userId');
    return await allData.filter( item =>{
        return item.userId.isMerchant == false;
    });
};

module.exports.getRentOut3 = async function(){
    const allData =  await mongose.model('commentsModel').find().populate('orderId').populate('userId');
    return await allData.filter( item =>{
        return item.userId.isMerchant == true;
    });
};

module.exports.getAll3 = async function(){
    return await mongose.model('commentsModel').find().populate('userId').populate('orderId');
}

module.exports.getByCd = async function({status=null,userId=null,orderId=null}){
     return await mongose.model('commentsModel').find({status,userId,orderId}).populate('userId').populate('orderId');
}

module.exports.add3 = async function(data){
    return await mongose.model('commentsModel').create(data);
}